package com.example.barcodeapp.adapter.gatheradapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.barcodeapp.R;
import com.example.barcodeapp.common.Constants;
import com.example.barcodeapp.ui.home.bean.JiaoShiLeiBiaoBean;

import java.util.List;

public class AdapterZhiBo extends RecyclerView.Adapter<AdapterZhiBo.ViewHolder> {
    Context context;


    public AdapterZhiBo(Context context) {
        this.context = context;
    }
    private List<JiaoShiLeiBiaoBean.DataEntity.ZhiboEntity> list;

    public AdapterZhiBo(Context context, List<JiaoShiLeiBiaoBean.DataEntity.ZhiboEntity> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.adapter_zhibo, parent, false);
        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Glide.with(context).load(Constants.Base_TPUrl2 +list.get(position).getHuodong_image()).into(holder.zhiboIv);
        holder.textView.setText(list.get(position).getHuodong_name());
        holder.textView2.setText(list.get(position).getHuodong_desc());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }


    public class ViewHolder extends RecyclerView.ViewHolder {
        private ImageView zhiboIv;
        private TextView textView;
        private TextView textView2;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            zhiboIv = (ImageView) itemView.findViewById(R.id.zhibo_iv);
            textView = (TextView) itemView.findViewById(R.id.textView);
            textView2 = (TextView) itemView.findViewById(R.id.neirong_zhibo);
        }
    }
}
